home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
tsptp.zip
/
TPBENCH.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-04-09
|
5KB
|
187 lines
(******************************************************************************)
(* TPBENCH.PAS *)
(* *)
(* Routines for internal timer used by the Pascal benchmarks. *)
(* *)
(******************************************************************************)
UNIT TPBench;
INTERFACE
USES Dos;
TYPE
(*** Benchmarking types. Note that Turbo 6-byte Reals have no exact ***)
(*** equivalent in TopSpeed Pascal. The TopSpeed Emulator however, ***)
(*** support 4, 8, and 10 byte floating point reals and an 8 byte fixed ***)
(*** point real that are equivalent to the Turbo Single, Double, ***)
(*** Extended and Comp types respectively. Because of this floating ***)
(*** point benchmarks should be run on a system with a coprocessor for ***)
(*** comparison. ***)
BmInt = LONGINT; (* -214783648..214783647, signed 32-bit *)
BmReal = REAL; (* 2.9E-39..1.7E+38 , 6 bytes *)
(*** Timing ***)
BmTimeT = LONGINT; (* Suitable type for max seconds *)
BmCounter = LONGINT; (* Suitable type for max loops *)
CONST
MINNULLTIME = 1; (* Null loop time in seconds *)
MINBENCHTIME = 60; (* Bench loop time in scoonds, 60 is good *)
VAR
DummyVar : BOOLEAN; (* Global variable for side-effects *)
(** STARTTIMER ****************************************************************
*
* Synopsis:
*
* StartTimer;
*
* Description:
*
* StartTime starts the benchmark timer.
*)
PROCEDURE StartTimer;
(** NULLTIMESUP ***************************************************************
*
* Synopsis:
*
* NullTimesUp;
*
* Description:
*
* NullTimesUp stops the timer when the NULL timing loop is complete.
*)
FUNCTION NullTimesUp: BOOLEAN;
(** BENCHTIMESUP **************************************************************
*
* Synopsis:
*
* BenchTimesUp;
*
* Description:
*
* BenchTimesUp stops the timer when the NULL timing loop is complete.
*)
FUNCTION BenchTimesUp: BOOLEAN;
(** REPORTTIMES ***************************************************************
*
* Synopsis:
*
* ReportTimes;
*
* Description:
*
* ReportTimes reports the benchmark times and stats. Note that the
* calculated results for LoopOverhead, TotalTime and Loops per second
* are prone to any floating point errors. Therefore you may wish to
* check these results manually.
*)
PROCEDURE ReportTimes;
(** DUMMY *********************************************************************
*
* Synopsis:
*
* Dummy;
*
* Description:
*
* Dummy is a dummy procedure used to calculate the looping overhead in a
* benchmark. In order to prevent it being optimised out of existence it
* must introduce a side effect. In this case we modify the exported
* variable DummyVar.
*)
PROCEDURE Dummy;
IMPLEMENTATION
VAR
Hours,
Minutes,
Seconds,
Hundredths : WORD;
NullLoops,
BenchLoops : BmCounter;
NullLoopTime,
BenchLoopTime,
StartTime,
NullTime,
BenchTime : BmTimeT;
PROCEDURE StartTimer;
BEGIN
Dos.GetTime(Hours, Minutes, Seconds, Hundredths);
StartTime := (((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths;
END;
FUNCTION NullTimesUp{: BOOLEAN};
BEGIN
Dos.GetTime(Hours, Minutes, Seconds, Hundredths);
NullTime := ((((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths)-StartTime;
NullLoops := NullLoops + 1;
NullTimesUp := (NullTime >= NullLoopTime);
END;
FUNCTION BenchTimesUp{: BOOLEAN};
BEGIN
Dos.GetTime(Hours, Minutes, Seconds, Hundredths);
BenchTime := ((((((Hours * 60)+Minutes)*60)+Seconds)*100)+Hundredths)-StartTime;
BenchLoops := BenchLoops + 1;
BenchTimesUp := (BenchTime >= BenchLoopTime);
END;
PROCEDURE ReportTimes;
VAR
RLoopOverhead : REAL;
RTotalTime : REAL;
BEGIN
RLoopOverhead := (NullTime/NullLoops)*BenchLoops;
RTotalTime := BenchTime-RLoopOverhead;
WriteLn('Benchmark times in seconds');
WriteLn('NullTime : ', NullTime/100:0:2);
WriteLn('BenchTime : ', BenchTime/100:0:2);
WriteLn('Null loops : ', NullLoops);
WriteLn('Bench loops : ', BenchLoops);
WriteLn('LoopOverhead : ', RLoopOverhead/100:0:2);
WriteLn('TotalTime : ', RTotalTime/100:0:2);
WriteLn('Loops per second : ', BenchLoops/(RTotalTime/100):0:2);
END;
PROCEDURE Dummy;
BEGIN
DummyVar := NOT DummyVar
END;
BEGIN
NullLoopTime := MINNULLTIME*100;
BenchLoopTime := MINBENCHTIME*100;
NullLoops := 0;
BenchLoops := 0;
DummyVar := TRUE;
END.